package com.memorypalace.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.memorypalace.deck.biz.ICardBiz;
import com.memorypalace.pojo.Card;
import com.memorypalace.pojo.StudyStatus;
import com.memorypalace.pojo.User;
import com.memorypalace.util.AJaxUtil;

@Controller
@RequestMapping("/card")
public class CardAction {

	@Autowired
	private ICardBiz cardBiz;
	
	@RequestMapping("/getdifficultcard")
	@ResponseBody
	public void getDifficultCard(HttpServletRequest request,HttpServletResponse response){
		String userId;
		User user = (User) request.getSession().getAttribute("user");
		userId = user.getUserId();
		List<Card> difficultCards= cardBiz.getCardInWrongCount(userId);
		AJaxUtil.sendJsonByObj(difficultCards, response);
	}
	@RequestMapping("/todaystudystatus")
	@ResponseBody
	public void getTodayStudyStatus(HttpServletRequest request,HttpServletResponse response){
		String userId;	
		User user = (User) request.getSession().getAttribute("user");
		userId = user.getUserId();
		StudyStatus studyStatus=	cardBiz.getCardStudyRecordInToday(userId);
		AJaxUtil.sendJsonByObj(studyStatus, response);
		
	}
	@RequestMapping("/historystudystatus")
	@ResponseBody
	public void getHistoryStudyStatus(HttpServletRequest request,HttpServletResponse response){
		String userId;
		User user = (User) request.getSession().getAttribute("user");
		userId = user.getUserId();
		List<StudyStatus> studyStatusList=cardBiz.getCardStudyRecordInThirtyDays(userId);
		AJaxUtil.sendJsonByObj(studyStatusList, response);
	}
}
